const common = require("./webpack.common");
// 对象合并
const { merge } = require("webpack-merge");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");

/**
 * 生产环境配置
 */
module.exports = merge(common, {
  mode: "production",
  plugins: [
    new CleanWebpackPlugin(),
    // 这种方式传参报错 Copy Plugin has been initialized using an options object that does not match the API
    // new CopyWebpackPlugin(["public"]),
    new CopyWebpackPlugin({
      patterns: [
        {
          from: __dirname + "/public",
          to: __dirname + "/dist",
        },
      ],
    }),
  ],
});
